layui.use(['table', 'admin', 'ax','laydate'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;
    var laydate = layui.laydate;

    laydate.render({
        elem: '#startTime'
        ,value:new Date()
    });

    laydate.render({
        elem: '#endTime'
        ,value:new Date()
    });

    /**
     * 临时工签到管理
     */
    var TransportRegistrationSignin = {
        tableId: "transportRegistrationSigninTable"
    };

    /**
     * 初始化表格的列
     */
    TransportRegistrationSignin.initColumn = function () {
        return [[
            {type: 'checkbox'},
            {field: 'id', hide: true, title: '主键'},
            {field: 'temporaryName', sort: true, title: '名字'},
            {field: 'tel', sort: true, title: '手机号'},
            {field: 'idcard', sort: true, title: '身份证号'},
            {field: 'laborServices', sort: true, title: '劳务公司'},
            {field: 'job', sort: true, title: '工作岗位'},
            {field: 'billingMode', sort: true, title: '计费模式'},
            {field: 'startTime', sort: true, title: '开始时间'},
            {field: 'v1', sort: true, title: '签到地址'},
            {field: 'endTime', sort: true, title: '结束时间'},
            {field: 'v2', sort: true, title: '签退地址'},
        ]];
    };

    /**
     * 点击查询按钮
     */
    TransportRegistrationSignin.search = function () {
        var queryData = {};
        queryData['startTime'] = $("#startTime").val();
        queryData['endTime'] = $("#endTime").val();
        queryData['condition'] = $("#condition").val();
        queryData['operateId'] = $("#operateId").val();
        table.reload(TransportRegistrationSignin.tableId, {
            where: queryData, page: {curr: 1},
            done:function () {
            }
        });
    };
    /**
     * 导出excel按钮
     */
    TransportRegistrationSignin.exportExcel = function () {
        var checkRows = table.checkStatus(TransportRegistrationSignin.tableId);
        if (checkRows.data.length === 0) {
            Feng.error("请选择要导出的数据");
        } else {
            table.exportFile(tableResult.config.id, checkRows.data, 'xls');
        }
    };
    // 渲染表格
    var tableResult = table.render({
        elem: '#' + TransportRegistrationSignin.tableId,
        url: Feng.ctxPath + '/transportRegistrationSignin/list',
        page: true,
        limit: 60,
        limits:[60,120,240,360,480,1500,5000],
        height: "full-60",
        toolbar: '#toolbarfrom',
        cellMinWidth: 100,
        cols: TransportRegistrationSignin.initColumn()
    });
    // 导出excel
    $('#btnExp').click(function () {
        TransportRegistrationSignin.exportExcel();
    });
    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        TransportRegistrationSignin.search();
    });
});
